package com.hongdee.crm.weChat.controller;

import com.hongdee.crm.weChat.service.ITBcOrganWechatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Liu XiaoLong
 * Date: 2017/10/24.
 * Remark:
 */
@RestController
@RequestMapping("/api/crm/shop")
public class WechatTBcOrganController {

    /**
     * @Name: 经纬度获取附近门店
     * @Author: Liu XiaoLong
     * @Date: 2017/11/1 11:21
     * @Remark:
     */
    @Autowired
    private ITBcOrganWechatService itBcOrganWechatService;
    @RequestMapping("/find/list")
    public Map getListByPosition(@RequestParam(name = "uid",defaultValue = "") String uid,
                                 @RequestParam(name = "token",defaultValue = "") String token,
                                 @RequestParam(name = "jd" ,defaultValue = "") String longtitude,
                                 @RequestParam(name = "wd",defaultValue = "") String latitude,
                                 @RequestParam(name = "vin",defaultValue = "") String vin,
                                 @RequestParam(name = "city",defaultValue = "") String city) throws Exception{

        Map map = new HashMap();
        map.put("data",itBcOrganWechatService.getOrganByPosition(uid,vin,city,longtitude,latitude));
        map.put("success",true);
        return map;
    }
    /**
     * @Name: 获取所有门店
     * @Author: Liu XiaoLong
     * @Date: 2017/10/26 09:34
     * @Remark:
     */
    @RequestMapping("/list")
    public Map getAllOrgan(@RequestParam(name = "uid",defaultValue = "") String uid,
                                 @RequestParam(name = "token",defaultValue = "") String token) throws Exception{

        Map map = new HashMap();
        map.put("data",itBcOrganWechatService.getAllOrgan(uid));
        map.put("success",true);
        return map;
    }

    /**
     * @Name: 通过vin查询上次门店
     * @Author: Liu XiaoLong
     * @Date: 2017/10/25 10:44
     * @Remark:
     */
    @RequestMapping("/find")
    public Map getlastOrgan(@RequestParam(name = "uid",defaultValue = "") String uid,
                            @RequestParam(name = "token",defaultValue = "") String token,
                            @RequestParam(name = "vin" ,defaultValue = "") String vin) throws Exception{
        Map map = new HashMap();
        map.put("data",itBcOrganWechatService.getLastOrganByVin(uid,vin));
        map.put("success",true);
        return map;
    }

}
